#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/10/19 10:36 AM
from django.contrib.auth.backends import ModelBackend
from rest_framework.exceptions import PermissionDenied


class BackEnd(ModelBackend):
    def user_can_authenticate(self, user):
        """
        Reject users with is_active=False. Custom user models that don't have
        that attribute are allowed.
        """
        if user.is_active is False:
            raise PermissionDenied
        return super(BackEnd, self).user_can_authenticate(user)
